package ioperation;

import Book.Book;
import Book.Booklist;

import java.util.Scanner;

/**
 * Created with Interllij IDEA.
 * Descriptiption:
 * User: 王澄慧
 * Date: 2022-04-16
 * Time: 20:18
 */
public class Addiperation implements IPeration{
    @Override
    public void work(Booklist booklist) {
        System.out.println("新增图书");
        System.out.println("请输入你要添加的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入图书的作者：");
        String author = scanner.nextLine();
        System.out.println("请输入图书的类型：");
        String type = scanner.nextLine();
        System.out.println("请输入图书的价格：");
        int price = scanner.nextInt();
        Book book = new Book(name,author,type,price);
        int currentSize = booklist.getUserSize();
        booklist.setBooks(currentSize,book);
        booklist.setUserSize(currentSize+1);
        System.out.println("添加成功");

    }
}
